
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 03/24/2013 23:52:12
-- Generated from EDMX file: C:\Users\colin_000\documents\visual studio 2012\Projects\MyFitness\MyFitness\Model\MyFitnessEntityDataModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [MyFitnessDatabase];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_Trainee_inherits_User]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Users_Trainee] DROP CONSTRAINT [FK_Trainee_inherits_User];
GO
IF OBJECT_ID(N'[dbo].[FK_Administrators_inherits_User]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Users_Administrators] DROP CONSTRAINT [FK_Administrators_inherits_User];
GO
IF OBJECT_ID(N'[dbo].[FK_Trainer_inherits_User]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Users_Trainer] DROP CONSTRAINT [FK_Trainer_inherits_User];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Users]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Users];
GO
IF OBJECT_ID(N'[dbo].[Users_Trainee]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Users_Trainee];
GO
IF OBJECT_ID(N'[dbo].[Users_Administrators]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Users_Administrators];
GO
IF OBJECT_ID(N'[dbo].[Users_Trainer]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Users_Trainer];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Users'
CREATE TABLE [dbo].[Users] (
    [LastName] nvarchar(max)  NOT NULL,
    [FirstName] nvarchar(max)  NOT NULL,
    [Email] nvarchar(50)  NOT NULL,
    [Password] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Users_Trainee'
CREATE TABLE [dbo].[Users_Trainee] (
    [Height] float  NOT NULL,
    [Weight] float  NOT NULL,
    [BirthDate] datetime  NOT NULL,
    [Gender] nvarchar(10)  NOT NULL,
    [Email] nvarchar(50)  NOT NULL
);
GO

-- Creating table 'Users_Administrators'
CREATE TABLE [dbo].[Users_Administrators] (
    [Email] nvarchar(50)  NOT NULL
);
GO

-- Creating table 'Users_Trainer'
CREATE TABLE [dbo].[Users_Trainer] (
    [Email] nvarchar(50)  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Email] in table 'Users'
ALTER TABLE [dbo].[Users]
ADD CONSTRAINT [PK_Users]
    PRIMARY KEY CLUSTERED ([Email] ASC);
GO

-- Creating primary key on [Email] in table 'Users_Trainee'
ALTER TABLE [dbo].[Users_Trainee]
ADD CONSTRAINT [PK_Users_Trainee]
    PRIMARY KEY CLUSTERED ([Email] ASC);
GO

-- Creating primary key on [Email] in table 'Users_Administrators'
ALTER TABLE [dbo].[Users_Administrators]
ADD CONSTRAINT [PK_Users_Administrators]
    PRIMARY KEY CLUSTERED ([Email] ASC);
GO

-- Creating primary key on [Email] in table 'Users_Trainer'
ALTER TABLE [dbo].[Users_Trainer]
ADD CONSTRAINT [PK_Users_Trainer]
    PRIMARY KEY CLUSTERED ([Email] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [Email] in table 'Users_Trainee'
ALTER TABLE [dbo].[Users_Trainee]
ADD CONSTRAINT [FK_Trainee_inherits_User]
    FOREIGN KEY ([Email])
    REFERENCES [dbo].[Users]
        ([Email])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Email] in table 'Users_Administrators'
ALTER TABLE [dbo].[Users_Administrators]
ADD CONSTRAINT [FK_Administrators_inherits_User]
    FOREIGN KEY ([Email])
    REFERENCES [dbo].[Users]
        ([Email])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Email] in table 'Users_Trainer'
ALTER TABLE [dbo].[Users_Trainer]
ADD CONSTRAINT [FK_Trainer_inherits_User]
    FOREIGN KEY ([Email])
    REFERENCES [dbo].[Users]
        ([Email])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------